#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Point(int = 0, int = 0)" << endl;
    }

    //this
    void print() const
    {
        if(this != nullptr)
        {
            cout << "(" << this->_ix
                 << ", " << _iy
                 << ")" << endl;
        }
        else
        {
            cout << "this == nullptr" << endl;
        }
    }

    ~Point()
    {
        cout << "~Point()" << endl;
    }

private:
    int _ix;
    int _iy;
};

void test()
{
    int number = 10;
    int *pInt = nullptr;
    /* pInt->print();//error */
    pInt = &number;

    Point pt(1, 2);//pt栈对象
    cout << "pt = ";
    pt.print();

    cout << endl;
    Point *ptr = nullptr;
    ptr = &pt;
    ptr->print();

    cout << endl;
    Point *pp = new Point(10, 40);
    pp->print();

    delete pp;
    pp = nullptr;
}


int main(int argc, char *argv[])
{
    test();
    return 0;
}

